package com.ewhale.feitengguest.utils;

import android.text.TextUtils;

import com.luck.picture.lib.entity.LocalMedia;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Author：SimGa
 * CoryRight：2018/9/21
 * PackageName：com.doupaitv.texaspoker.utils
 */
public class ImagePart {

    public static final List<RequestBody> getPart(List<LocalMedia> paths) {
        if (paths != null) {
            ArrayList<RequestBody> parts = new ArrayList();
            Iterator var4 = paths.iterator();
            while (var4.hasNext()) {
                LocalMedia path = (LocalMedia) var4.next();
                if (path != null) {
                    File file = !TextUtils.isEmpty(path.getCompressPath()) ? new File(path.getCompressPath()) : (!TextUtils.isEmpty((CharSequence) path.getCutPath()) ? new File(path.getCutPath()) : new File(path.getPath()));
                    RequestBody requestBody = RequestBody.create(MediaType.parse(path.getPictureType()), file);
//                    MultipartBody.Part image = MultipartBody.Part.createFormData("image", file.getName(), requestBody);
                    parts.add(requestBody);
                }
            }

            return (List) parts;
        } else {
            return null;
        }
    }
}
